#ifndef __MOTOR_H__
#define __MOTOR_H__

#include "gpio.h"
#include "tim.h"

typedef struct _MOTOR {
  TIM_HandleTypeDef *htim_encoder;
  TIM_HandleTypeDef *htim_pwm;
  uint32_t channel;
  GPIO_TypeDef *port1;
  uint16_t pin1;
  GPIO_TypeDef *port2;
  uint16_t pin2;

  void (*Driver)(struct _MOTOR *motor, int16_t pwm);
} Motor;

void Motor_Init(Motor *motor, TIM_HandleTypeDef *htim_pwm, uint32_t channel,
                GPIO_TypeDef *port1, uint16_t pin1, GPIO_TypeDef *port2, uint16_t pin2);


#endif /* __MOTOR_H__ */
